#include "header.h"
#define BUFF_SIZE 1024

/*Usage: ./file copy src to dest*/
int main(int argc, char* argv[]){
	ARGS_CHECK(argc, 3);
	int src_fd = open(argv[1], O_RDONLY);
	ERROR_CHECK(src_fd, -1, "open src");

	int dest_fd = open(argv[2], O_CREAT | O_WRONLY, 0666);
	ERROR_CHECK(dest_fd, -1, "open src");

	char buf[BUFF_SIZE] = {0};
	int cnt;
	while((cnt = read(src_fd, buf, sizeof buf)) > 0){
		write(dest_fd, buf, cnt);
	}


	close(src_fd);
	close(dest_fd);
	return 0;
}